/**	@file tests.h */
#ifndef testsForSympyCpp_majdo
#define testsForSympyCpp_majdo
#include <string>
#include <iostream>
#include "Expr.h"
namespace sympycpp {
/**	@class TestX
 * 	@brief Test framework.
 * 	This class provides ability to testing of expressions.*/	
class TestX{
private:
	/**	@brief Level of messages. */
	int voiceLevel_;	
	/**	@brief attribute of printing of tree*/
	bool tree_;
public:
	TestX(const int v = 3, const bool t = false) : voiceLevel_(v % 4), tree_(t) {}
	void setTree(const bool t) {
		tree_ = t;
	}
	bool setVoice(const int v) {
		if (v < 0 || v > 3) {
			return false;
		}
		else {
			voiceLevel_ = v;
			return true;
		}
	}
	/**	@brief Test function.
	 * 	@param e is a tested expression
	 * 	@param rightExp is the correct textual form of the tested expression
	 * 	@param line is line in file (use __FILE__))
	 * 	@param nT is a number of test*/
	void test(const Expr & e, const std::string rightExp, const int line = -1, const int nT = 0) const {
		if (e.str() == rightExp) {
			switch (voiceLevel_) {
				case 0:
					break;
				case 1:
					std::cout << "OK[" <<  line << ":" << nT << "] ";
					break;
				case 2:
					std::cout << "OK[" <<  line << ":" << nT << "] ";
					break;
				case 3:
					std::cerr << std::endl << "OK[" <<  line << ":" << nT << "] |>" << e.str() << "<|>" << rightExp << "<|"<< std::endl;
					break;
					
			}
		}
		else {
			switch (voiceLevel_) {
				case 0:
					std::cerr << std::endl << "Fail[" <<  line << ":" << nT << "] |>" << e.str() << "<|>" << rightExp << "<|" << std::endl;
					break;
				case 1:
					std::cerr << "Fail[" <<  line << ":" << nT << "] " << std::endl;
					break;
				default:
					std::cerr << std::endl << "Fail[" <<  line << ":" << nT << "] |>" << e.str() << "<|>" << rightExp << "<|" << std::endl;
					break;
			}

		}
		if (tree_ && nT != 0) {
			e.tree();	
		}
	}
};
}
#endif
